<template>
<div>
  <!--  分割线-->
  <el-divider></el-divider>

  <el-form :inline="true" :model="docFormInline" class="demo-form-inline">
    <el-form-item>
      <el-input v-model="docFormInline.docValues"></el-input>
    </el-form-item>
    <el-form-item>
      <el-select clearable v-model="docFormInline.docOptions" placeholder="--请选择搜索对象--">
        <el-option label="上传人" value="userName"></el-option>
        <el-option label="所属文件夹" value="folderName"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" plain @click="getRecordDocument">查询</el-button>
    </el-form-item>
  </el-form>
  <el-table
      :data="RecordDocumentData"
      style="width: 100%">
    <el-table-column
        prop="caseNo"
        label="案号">
    </el-table-column>
    <el-table-column
        prop="folderName"
        label="所属文件夹">
    </el-table-column>
    <el-table-column
        prop="userName"
        label="上传人">
    </el-table-column>
    <el-table-column
        prop="upddate"
        label="更改日期">
    </el-table-column>
    <el-table-column
        label="操作">
      <template slot-scope="scope">
        <el-dropdown trigger="click">
          <el-button type="primary" plain>
            操作<i class="el-icon-arrow-down el-icon--right"></i>
          </el-button>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item @click.native="selectRecordDoc(scope.row)">下载</el-dropdown-item>
            <el-dropdown-item @click.native="deleteRecordDoc(scope.row.id)">删除</el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </template>
    </el-table-column>
  </el-table>
  <!--    分页-->
  <el-pagination
      background
      layout="total, sizes, prev, pager, next"
      :page-sizes="[2, 4, 6, 8]"
      :total="pageDataDoc.total"
      :page-size="docFormInline.pageNum"
      @size-change="docHandleSizeChange"
      @current-change="docHandleCurrentChange">
  </el-pagination>
</div>
</template>

<script>
export default {
  name: "RecordDocumentAll.vue",
  data(){
    return{
      RecordDocumentData: [],//查询我的电子文档表格
      pageDataDoc:{},// 存储返回的分页数据
      //高级查询我的电子归档
      docFormInline: {
        docValues: '',
        docOptions: '',
        pageId: 1,
        pageNum: 2,
      },
    }
  },
  created() {
    this.getRecordDocument();
  },
  methods:{
    //查询我的电子文档
    getRecordDocument() {
      this.$http.get('recordDocument', {params: this.docFormInline})
          .then((res) => {
            this.RecordDocumentData = res.data.data.list;//查询出来的数据
            this.pageDataDoc = res.data.data; // 返回的分页参数   pageinit
          })
          .catch(function (error) {
            console.log(error);
          });
    },
    //下载
    selectRecordDoc(row){
      document.location.href=row.documentFile
    },
    //删除
    deleteRecordDoc(id){
      this.$http.delete(`recordDocument/${id}`)
          .then(
              this.$notify({
                type:"success",
                message:"删除成功"
              }),
              this.getRecordDocument()
          )
          .catch(function (error) {
            console.log(error);
          });
    },
    //显示几页
    docHandleSizeChange(val) {
      this.docFormInline.pageNum = val;
      this.getRecordDocument();
    },
    //每页显示几条
    docHandleCurrentChange(val) {
      this.docFormInline.pageId = val;
      this.getRecordDocument();
    },
  }
}
</script>

<style scoped>

</style>